import type { QmsCollectRecord } from "@/pages/qms/collectRecord/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
  //物料ID
  materialId?: number;
  //岗位ID
  postId?: number;
  //缺陷编码
  defectCode?: string;
  //检验项类型
  indexType?: string;
  //采集时间
  collectTime?: Date;
  //当前页码
  page: number;
  //每页数量
  pageSize: number;
}

export interface PageListRes {
  //总记录数
  total: number;
  //数据列表
  records: QmsCollectRecord[];
}

const pageList = (data: PageListReq): Promise<PageListRes> =>
  apiClient.post({
    url: "/qms/collect/record/pageList",
    data
});
const getInfo = (id: React.Key): Promise<QmsCollectRecord> =>
  apiClient.get({
    url: `/qms/collect/record/${id}`
});

const add = (data: QmsCollectRecord): Promise<QmsCollectRecord> =>
  apiClient.post({
    url: "/qms/collect/record",
    data
});

const update = (data: QmsCollectRecord): Promise<QmsCollectRecord> =>
  apiClient.put({
    url: "/qms/collect/record",
    data
});

const remove = (ids: React.Key[]): Promise<void> =>
  apiClient.delete({
    url: "/qms/collect/record",
    params: {
    ids: ids.join(",")
  }
});
export const qmsCollectRecordService = {
  pageList,
  getInfo,
  add,
  update,
  remove,
};

export default qmsCollectRecordService;